#pragma once

#ifndef _CITEMCONTAINER_H_
#define _CITEMCONTAINER_H_

#include <vector>

#include "CSemaphore.h"

#include "CGeneralItem.h"
#include "CWeaponItem.h"
#include "CArmorItem.h"
#include "CPuppetItem.h"
#include "CUsableItem.h"
#include "CLinkshellItem.h"

class CChar;

class CItemContainer {

public:
	CItemContainer(unsigned char locationID, CChar * owner);
	~CItemContainer();

	unsigned char getId();
	void setId(unsigned char id);

	unsigned char getSize();
	void setSize(unsigned char size);


	// returns slot where new item was placed
	unsigned char addItem(unsigned short itemID, unsigned long quantity);
	// uses database to create correct item type and stats
	CItem * createItem(unsigned short itemID);

	CItem * getItem(unsigned char slotID);
	void setItem(unsigned char slotID, CItem * item);

	unsigned long getQuantity(unsigned char slotID);
	unsigned char getType(unsigned char slotID);

	void updateItem(unsigned char slotID, CItem * item);

	// returns slot where item was moved into
	unsigned char moveItemTo(CItem * item);

	void removeItem(unsigned char slotID);
	void removeQuantity(unsigned char slotID, unsigned long quantity);

	unsigned long getItemQuantity(unsigned short itemID);

	void loadSQL(unsigned char containerID);
	void updateSQL(unsigned char slotID);

	void setOwner(CChar * owner);
	CChar * getOwner();

private:
	unsigned char m_id;
	unsigned char m_size;
	CItem ** m_itemList;

	CChar * m_pOwner;
};

#endif